Skip to content

Conversation

@LumenGNU
Copy link

Adding TypeScript interfaces for GNOME Shell search providers

Description of Changes

Added two TypeScript interfaces to extensions/global.d.ts:

  • SearchProvider2 - main interface for implementing search providers in GNOME Shell extensions
  • ResultMeta - helper type for structured metadata transfer of search results

Reason for Changes

When developing extensions that implement search providers for GNOME Shell using TypeScript, there are no typed interfaces available, which complicates development and removes the benefits of static typing.

The existing approach often involves implementing from concrete classes (like AppSearchProvider):

import { AppSearchProvider } from "resource:///org/gnome/shell/ui/appDisplay.js";
export class MySearchProvider implements AppSearchProvider {}

This approach has drawbacks due to imperfect typing of existing classes.

The added interfaces allow for a cleaner and type-safe approach:

import { SearchProvider2, ResultMeta } from '@girs/gnome-shell/extensions/global';
export class MySearchProvider implements SearchProvider2 {}

How it was tested

The interfaces were tested in a real GNOME Shell extension. Usage examples can be provided upon request.

Special notes

  • The SearchProvider2 interface represents the implementation contract needed for GNOME Shell search providers in GJS. In GJS this interface doesn't have a formal name (it's just implemented), but for TypeScript typings it needs a name. The name "SearchProvider2" was chosen to match what's observed in the internal GNOME Shell code and D-Bus naming convention
  • Implementation follows the requirements and recommendations from the official guide: https://gjs.guide/extensions/topics/search-provider.html
  • The interface has been adjusted based on observations of actual GNOME Shell behavior
  • The name ResultMeta was chosen to reflect its role in transferring metadata about search results
  • Interfaces have been added to global definitions, making them available via import from @girs/gnome-shell/extensions/global

Note: This PR description was translated to English by Claude the Absentminded. Any misrepresentations of the original intent are purely coincidental and should be blamed on artificial neural fluctuations. 😄

Copy link
Collaborator

@swsnr swsnr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As these interfaces do not correspond to an actual type in GNOME Shell, please move them to a new file under the types sub-module, e.g. packages/gnome-shell/src/types/search-provider.ts, and then re-export that from packages/gnome-shell/src/types/index.ts.

@LumenGNU
Copy link
Author

I made the changes requested in the comment to PR #89 - moved the SearchProvider2 and ResultMeta interfaces to the types module.

However, I encountered a problem: I couldn't import these interfaces in my test project. (nor any other types from the types module).
Снимок экрана от 2025-10-21 11-22-06

Is there any documentation or recommendations on how to properly import types from the types module?

Perhaps I misunderstood the comment, and these interfaces should still be re-exported through extensions/global.d.ts?

@swsnr
Copy link
Collaborator

swsnr commented Oct 22, 2025

@LumenGNU Looks as if we didn't export the types module yet. Just add it to package.json as export.

@LumenGNU LumenGNU closed this by deleting the head repository Oct 23, 2025
@swsnr
Copy link
Collaborator

swsnr commented Oct 25, 2025

@LumenGNU Did you close this deliberately? Just to clarify, I'd have merged these changes, so perhaps you might want to follow up on this PR?

@LumenGNU
Copy link
Author

I apologize for the confusion. I didn't intend to close the PR deliberately - it happened automatically when I was reorganizing my repository connections. I was actually doing some "digital housekeeping" and didn't realize this would affect the open pull request.

Regarding the interfaces I proposed, they will still be available in https://github.com/LumenGNU/ManSearchProvider/tree/main/src/types if you find them useful. I agree that it's challenging to determine their ideal location in the current state of the project. This might sort itself out naturally as types for search.js and searchController.js modules take shape.

Thank you for following up on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants